from datetime import timedelta, datetime, timezone
from typing import Union

from settings import JwtConfig
from utils.jwt_util import JWTUtil

from app.admin.schema.login import PayLoad

class LoginService():
    
    @classmethod
    async def create_access_token(
        cls, 
        payload: PayLoad, 
    ) -> str:
        """生成 token

        Args:
            data (dict): 负载信息
            expires_delta (Union[timedelta, None], optional): 过期时间.

        Returns:
            str: token
        """
        token = JWTUtil.encode_dict(payload.model_dump().copy())
        return token